# Estimating the Spillover Economic Effects of Foreign Conflict: Evidence from Boko Haram

---
Authors: Remi Jedwab, Brian Blankespoor, Takaaki Masaki and Carlos Rodríguez-Castelán
Data Input Script: Brian Blankespoor
---

## Overview

The code in this replication package constructs the analysis file from external data sources and local data using R, Stata and python. A main R script runs all of the code to generate the input data for the manuscript entitled, "Estimating the Spillover Economic Effects of Foreign Conflict: Evidence from Boko Haram". The replicator should expect the code to run for about 24 hours and require at least 40GB of data.

## Data Availability and Provenance Statements

### Statement about Rights

- I certify that the author(s) of the manuscript have legitimate access to and permission to use the data used in this manuscript. 

### License for Data

The data are licensed under a Creative Commons/CC-BY-NC license.

### Summary of Availability
- Some data **cannot be made** publicly available. The user must download or request data 

## Dataset list

local data directory has three categories: ee_data, gis_data and tab_data.  

|---------------------------------------------------------------|--------|----------|---------|
| Data file 							| Source | Notes    |Provided |
|---------------------------------------------------------------|--------|----------|---------|
| local/ee_data										      |
| `burned_area/lake_chad_ntl_ctr_x_d01_sum_burned_area_ts*.csv` | MODIS  | Public   | No      |
| `ndvi/lake_chad_gridid_mean_NDVI_mod13_ts*.csv` 		| MODIS  | Public   | No      |
| `npp/lake_chad_ntl_ctr_x_d01_sum_psnnet_ts*.csv` 		| MODIS  | Public   | No      |
|---------------------------------------------------------------|--------|----------|---------|


|---------------------------------------------------------------|----------|---------|--------|
| Data file 							| Source   | Notes   |Provided|
|---------------------------------------------------------------|----------|---------|--------|
| local/gis_data									      |
| `001_farming/TLU_units.xlsx` 					| FAO 	   | Public  | No     |
| `001_farming/SPAM_2010_v2r0/spam2010V2r0_global_P_COTT_A.tif` | IFPRI	   | Public  | No     |
| `001_farming/SPAM_2010_v2r0/spam2010V2r0_global_P_GROU_A.tif` | IFPRI	   | Public  | No     |
| `001_farming/GLW/livestock_6_Ch_2010_Aw.tif`		        | Gilbert& | Public  | API    |
| `001_farming/GLW/livestock_6_Ct_2010_Aw.tif`		        | al. 2018 | Public  | API    |
| `001_farming/GLW/livestock_6_Gt_2010_Aw.tif`		        | 	   | Public  | API    |
| `001_farming/GLW/livestock_6_Ho_2010_Aw.tif`		        | 	   | Public  | API    |
| `001_farming/GLW/livestock_6_Pg_2010_Aw.tif`		        | 	   | Public  | API    |
| `001_farming/GLW/livestock_6_Sh_2010_Aw.tif`		        | 	   | Public  | API    |
| `003_boundaries/ne_50m_WB_admin_0_boundary_lines.shp` 	| WB 	   | Public  | No     |
| `003_boundaries/ne_50m_WB_admin_0_boundary_lines_disputed.shp`| WB 	   | Private | No     |
| `003_boundaries/ne_50m_WB_coastline.shp` 			| WB 	   | Public  | No     |
| `003_boundaries/fishnet_lake_chad_ntl_x_d01.shp` 		| Authors  | Public  | Yes    |
| `003_boundaries/lake_chad/lake_chad_adm0.shp` 		| GADM 3.6 | Public  | Yes    |
| `003_boundaries/lake_chad/gadm36_lake_chad_ctr_1.shp` 	| GADM 3.6 | Public  | No     |
| `003_boundaries/lake_chad/gadm36_lake_chad_ctr_2.shp` 	| GADM 3.6 | Public  | No     |
| `003_boundaries/lake_chad/gadm36_lake_chad_ctr_3.shp` 	| GADM 3.6 | Public  | No     |
| `003_boundaries/bh3s.shp` 					| Authors  | Private | No     |
| `003_boundaries/bhb.shp` 					| Authors  | Private | No     |
| `003_boundaries/bhbr.shp` 					| Authors  | Public  | Yes    |
| `003_boundaries/fishnet_pt.dbf` 				| Authors  | Public  | Yes    |
| `003_boundaries/fishnet_pt_all_with_NER_adm4_feb2018.dbf` 	| Authors  | Private | No     |
| `003_boundaries/lake_chad_latest/..  				| Authors  | Private | No     |
| 	lake_chad_region_dissolved.shp`				|          |         |        |
| `003_boundaries/Lakes_for_Brian/big_lake.shp`			| Authors  | Private | No     |
| `003_boundaries/Lakes_for_Brian/ne_10m_lakes.shp`		| NE  	   | Private | No     |
| `006_elevation/meanslope/meanslope` 				| Verdin & |	     |        |
|								  al. 2007 | Public  | No     |
| `007_environment/landcover/ESACCI-LC` 			| ESA      | Public  | No     |
| `010_imageryBaseMaps/DMSP_stable_lights` 			| NOAA     | Public  | No     |
| `010_imageryBaseMaps/NTL_harmonized` 				| Li & al  |         |        |
|								|   2020   | Public  | No     |
| `010_imageryBaseMaps/VIIRS/VIIRS2_0` 				| Elvidge &|         |        |
|								|  al. 2017| Public  | No     |
| `016_soceity/Africapolis_2015/..				| Authors  | Private | No     |
|	fishnet_pt_all_with_NER_adm4_feb2018.dbf` 		| 	   |         |        |
| `016_society/Africapolis_2015/africapolis.shp` 		| Africapolis|Private| No     |
| `016_society/PETRO_dataset_080907/PETRO_Onshore_080907.shp` 	| Lujala & | Public  | No     |
								  al. 2007 | 	     |        |
| `016_society/GREG/GREG.shp`				 	| Weidmann&| Public  | No     |
|								|   al.2020|	     |	      |	
| `016_society/Ethnicity_murdock/Murdock_EA_2011_vkZ.shp` 	| Murdock& | Public  | No     |
|								|   1959   |	     |        |
| `018_transportation/roads/rds_remi_afr.shp` 			| Jedwab & | Private | No     |
| `018_transportation/roads/roads_panel.shp` 			|Storeygard|  	     |        |
| `018_transportation/roads/roads_NW_transcon_2008.TAB` 	| 2020	   |  	     |        |
| `018_transportation/border_crossings_chad_basin_2008_v1.shp`	| 	   | 	     |        |
| `018_transportation/Airport/airports2008globalGIS.csv`	| USGS 2003| 	     | 	      |
| `019_utilitiesCommunication/electricity/..			| AICD 	   | Private | No     |
|  	AICD_ALL Countries Electricity Transmission Network`	|  	   | 	     | 	      |
| `Groundwater_Depth/DepthToGroundwater2021/..			|MacDonald&| Private | No     |
|  	Finalcombined_map/dtgw_20211.tif`			| al. 2012 | 	     | 	      |
| `019_utilitiesCommunication/powerplants_aicd/..		| AICD 	   | Private | No     |
|  	CMR_PowerPlants.shp`					|  	   | 	     | 	      |
|  	NER_PowerPlants.shp`					|  	   | 	     | 	      |
|  	NGA_PowerPlants.shp`					|  	   | 	     | 	      |
|  	TCD_PowerPlants.shp`					|  	   | 	     | 	      |
| `019_utilitiesCommunication/powerplants_wri/..		| WRI 	   | Public  | No     |
|  	global_power_plant_database.csv`			|  	   | 	     | 	      |
|---------------------------------------------------------------|----------|---------|--------|



|---------------------------------------------------------------|--------|-----------|--------|
| Data file 							| Source | Notes     |Provided|
|---------------------------------------------------------------|--------|-----------|--------|
| local/tab_data									      |	
| `Africa_1997-2020_Mar28-1.xlsx` 				| ACLED  | Public    | No     |
| `SCAD2018Africa_Final.csv.zip` 				| SCAD   | Public    | API    |
| `ged201.RData` 						| UCDP   | Public    | API    |
|---------------------------------------------------------------|--------|-----------|--------|


## Computational requirements

### Software Requirements

- The replication package contains one or more programs to install all dependencies and set up the necessary directory structure. 

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2016 x64 (build 14393)

- R 4.3.1
attached base packages:
[1] parallel  tools     stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] spatialEco_2.0-2     openxlsx_4.2.5.2     purrr_1.0.2          rSDM_0.4.0          
 [5] readxl_1.4.3         ggpattern_1.1.3      exactextractr_0.10.0 doSNOW_1.0.20       
 [9] snow_0.4-4           gdistance_1.6.4      Matrix_1.6-1.1       igraph_1.5.1        
[13] fasterize_1.0.5      lwgeom_0.2-13        rgeos_0.6-4          readstata13_0.10.1  
[17] rgdal_1.6-7          patchwork_1.2.0      raster_3.6-26        sp_2.1-2            
[21] ggpubr_0.6.0         colourvalues_0.3.9   XML_3.99-0.14        dplyr_1.1.3         
[25] stars_0.6-4          abind_1.4-5          gt_0.10.0            xfun_0.40           
[29] modelsummary_1.4.5   ordinal_2023.12-4    terra_1.7-55         archive_1.1.8       
[33] RColorBrewer_1.1-3   R.utils_2.12.2       R.oo_1.25.0          R.methodsS3_1.8.2   
[37] ggplot2_3.5.1        renv_1.0.5           tidyr_1.3.0          nngeo_0.4.7         
[41] foreign_0.8-84       doParallel_1.0.17    iterators_1.0.14     foreach_1.5.2       
[45] data.table_1.14.8    readr_2.1.4          Hmisc_5.1-2          stringr_1.5.1       
[49] httr_1.4.7           sf_1.0-19           

loaded via a namespace (and not attached):
 [1] DBI_1.2.3           gridExtra_2.3       remotes_2.4.2.1     rlang_1.1.5         magrittr_2.0.3     
 [6] e1071_1.7-16        compiler_4.3.1      vctrs_0.6.3         pkgconfig_2.0.3     fastmap_1.1.1      
[11] backports_1.4.1     utf8_1.2.3          rmarkdown_2.25      tzdb_0.4.0          broom_1.0.5        
[16] cluster_2.1.4       R6_2.5.1            tables_0.9.17       stringi_1.7.12      car_3.1-2          
[21] rpart_4.1.19        cellranger_1.1.0    numDeriv_2016.8-1.1 Rcpp_1.0.11         knitr_1.44         
[26] base64enc_0.1-3     nnet_7.3-19         tidyselect_1.2.0    rstudioapi_0.15.0   codetools_0.2-19   
[31] lattice_0.22-5      tibble_3.2.1        withr_3.0.0         evaluate_0.21       units_0.8-5        
[36] proxy_0.4-27        zip_2.3.0           xml2_1.3.5          pillar_1.9.0        carData_3.0-5      
[41] KernSmooth_2.23-21  checkmate_2.3.1     insight_0.19.10     generics_0.1.3      hms_1.1.3          
[46] munsell_0.5.0       scales_1.3.0        class_7.3-22        glue_1.6.2          ggsignif_0.6.4     
[51] grid_4.3.1          colorspace_2.1-0    nlme_3.1-162        htmlTable_2.4.2     Formula_1.2-5      
[56] cli_3.6.1           fansi_1.0.4         gtable_0.3.4        rstatix_0.7.2       digest_0.6.33      
[61] classInt_0.4-11     ucminf_1.2.1        htmlwidgets_1.6.2   htmltools_0.5.6     lifecycle_1.0.4    
[66] MASS_7.3-60          

### Controlled Randomness

- No Pseudo random generator is used in the analysis described here.

### Memory, Runtime, Storage Requirements

#### Summary

Approximate time needed to reproduce the analyses on a standard 2024 server machine:
- 8-24 hours

Approximate storage space needed:
- 25 GB - 250 GB

#### Details

Portions of the code were last run on a 32-core Intel server with 256 GB of RAM, 100 GB of network storage. 

## Description of programs/code
- Script bh_spillover_wd__data_input_main.R is the main script
- User must specify directories for Stata, Python 
- Scripts starting with do_prep use stata to construct and compile intermediate data
- Scripts with .py require ESRI arcpy library

## List of programs

The provided code reproduces:
- Input data in the paper

| Dataset         	      | Program(s)               	     	  | Theme              ||
|-----------------------------|-------------------------------------------|--------------------||
| GRID.dta        	      | fishnet_xy_intersection.py		  | Grid cell	       ||
| TREAT.dta       	      | bh_spillover_do_prep_grid_treatment.do	  | Treatment	       ||
| NER_ADM4.dta    	      | do_prep_ner_adm4.do			  | Boundary	       ||
| NTL_POP_ts.dta  	      | do_prep_bh_ntl_pop_acled.do		  | Night time lights  ||
| NTLH9218.dta    	      | agrprep_ntl_harmonized.R		  | Night time lights  ||
| 	          	      | do_prep_ntl_harmonized.do		  | Night time lights  ||
| NTL_VIIRS_vars_1220.dta     | do_prep_viirs_v2_from_tifs.do		  | Night time lights  ||
| ACLED_w_types_0018_ts3.dta  | prep_acled_data_all_1999_2015.r		  | Conflict	       ||
| 			      | do_prep_bh_acled_conflict_w_type_grid.do  | Conflict	       ||
| SCAD_loc_level.dta	      | prep_scad.r				  | Conflict	       ||
| 			      | do_prep_bh_scad.do			  | Conflict	       ||
| UCDP_loc_level.dta	      | prep_conflict_ucdp.r			  | Conflict	       ||
| 			      | do_prep_ucdp.do				  | Conflict	       ||
| DIST.dta		      | prep_zonal_extract_boko_haram.R		  | Distance	       ||
| 			      | do_prep_distvars.do			  | Distance	       ||
| DIST_CMR.dta		      | prep_zonal_extract_boko_haram_dist.R	  | Distance	       ||
| 			      | do_prep_dist_cmr.do			  | Distance	       ||
| tt2bhbr.dta &		      | bh_spillover_wd_travel_time2port.R	  | Travel time	       ||
| TT_CONTROL_CITIES.dta	      | do_prep_tt2bhbr.do			  | Travel time	       ||
| 			      | do_prep_bh_tt_city_controls.do		  | Travel time	       ||
| WBLKC.dta		      | prep_lake_chad_boundary.R		  | Boundary	       ||
| DIST2LAKECHAD.dta	      | dist2lakechad.R				  | Distance	       ||
| 			      | do_prep_world_bank_lake_chad_boundary.do  | Distance	       ||
| BURN_mo_ts.dta	      | do_prep_bh_burn_month_ts.do		  | Burned area	       ||
| NDVI_mo_ts.dta	      | do_prep_bh_burn_ndvi_ts.do		  | Land	       ||
| LULCfreq_ts_v2.dta	      | prep_bh_landcover_reclass_crosstab*.R	  | Land	       ||
| 			      | do_bh_prep_lulc_velox2.do		  | Land	       ||
| LULC08_share*.dta	      | bh_spillover_wd_prep_landcover_reclass*.R | Land 	       ||
| GRID_BORDER.dta	      | do_prep_grid_borders.do			  | Boundary	       ||
| OILPROD.dta		      | do_prep_petro_onshore_in_fishnet.do	  | Natural resources  ||
| OILREF.dta		      | 					  | Natural resources  ||
| URANMINE.dta		      |  					  | Natural resources  ||
| IDPREF.dta		      | do_prep_idpref_in_fishnet.do		  | Refugee	       ||
| ROADS.dta &		      | prep_road_measures.py			  | Infrastructure     ||
| ROADTYPEM_ts*.dta	      | road_length.r				  | Infrastructure     ||
| 			      | do_prep_road_intersections.do		  | Infrastructure     ||
| 			      | do_prep_road_length_ts.do		  | Infrastructure     ||
| DIST2ROADS.dta	      | dist2roads.r				  | Distance	       ||
| AIRPORT.dta		      | do_prep_airports.R			  | Infrastructure     ||
| 			      | do_prep_airports.do			  | Infrastructure     ||
| COTT.dta		      | cotton_production.R			  | Agriculture        ||
| 			      | do_prep_cotton.do			  | Agriculture        ||
| ELEC_all.dta		      | dist2electricity.R			  | Infrastructure     ||
| 			      | do_prep_dist2elec.do			  | Infrastructure     ||
| DIST2PP_all.dta	      | dist2powerplant.R			  | Infrastructure     ||
| 	    		      | do_prep_dist2powerplant.do		  | Infrastructure     ||
| POLICITYDIST.dta	      | do_prep_political_city.R		  | Society            ||
| 			      | do_prep_political_cities.do		  | Society            ||
| BUILT_POP.dta		      | prep_ghs_pop_and_builtup.R		  | Society	       ||
| 			      | do_prep_ghs_new.do			  | Society	       ||
| ETHNICgreg.dta &	      | prep_ethnic_greg.py			  | Society	       ||
| ETHNICmurd.dta	      | do_prep_ethnic_v2.do			  | Society	       ||
| GNUT.dta		      | groundnut_production.R			  | Agriculture        ||
| 			      | do_prep_groundnut.do			  | Agriculture        ||
| AGSUIT.dta		      | prep_ag_suit_afclima.R			  | Agriculture        ||
| 			      | do_prep_ag_suit_v2.do			  | Agriculture        ||
| LANDSUIT_share*.dta	      | sh_area_land_suitability.R		  | Agriculture        ||
| DIST2BCROSS.dta	      | dist2border_post_in_country.r		  | Distance           ||
| 			      | do_prep_dist2border_crossing.do		  | Distance           ||
| CROSSWALKsorted.dta	      | prep_crosswalk_grid01_x_adm1.r		  | Grid	       ||
| 			      | do_prep_crosswalk.do			  | Grid	       ||
| MA_NTL_TT_HR08.dta	      | prep_ma_ntl_tt_excl20km_server_ts*.r	  | Infrastructure     ||
| GWDEPTH_share*.dta 	      | sh_area_gw_depth_cat.R			  | Water	       ||
| LIVESTOCK_TLU_buffalo*.dta  | livestock_production.R			  | AGRICULTURE	       ||
| LIVESTOCK_TLU_cattle*.dta   | 			  		  | AGRICULTURE	       ||
| LIVESTOCK_TLU_chickens*.dta | 			  		  | AGRICULTURE	       ||
| LIVESTOCK_TLU_goats*.dta    | 			  		  | AGRICULTURE	       ||
| LIVESTOCK_TLU_horses*.dta   | 			  		  | AGRICULTURE	       ||
| LIVESTOCK_TLU_pigs*.dta     | 			 		  | AGRICULTURE	       ||
| LIVESTOCK_TLU_sheep*.dta    | 			  		  | AGRICULTURE	       ||
| DIST2TRANS_IMP_roads*.dta   | dist2transcontinental_roads.R	  	  | Infrastructure     ||
| WOODYBIOMASS*.dta 	      | woody_biomass.R		  		  | Land	       ||
|-----------------------------|-------------------------------------------|--------------------||


## References

Bouvet, A., Mermoz, S., Le Toan, T., Villard, L., Mathieu, R., Naidoo, L., & Asner, G. P. (2018). An above-ground biomass map of African savannahs and woodlands at 25 m resolution derived from ALOS PALSAR. Remote sensing of environment, 206, 156-173.

Byers, L., Friedrich, J., Hennig, R., Kressig, A., Li, X., McCormick, COLIN & Valeri, L. M. (2018). A global database of power plants. World Resources Institute, 18.

C. D. Elvidge, K. Baugh, M. Zhizhin, F. C. Hsu, and T. Ghosh (2017). “VIIRS night-time lights,” International Journal of Remote Sensing, vol. 38, pp. 5860–5879.  

GADM Database of Global Administrative Boundaries (GADM) (2020). GADM: Global administrative areas [Version 3.6]. Retrieved from https://gadm.org

Gilbert M, G Nicolas, G Cinardi, S Vanwambeke, TP Van Boeckel, GRW Wint, TP Robinson (2018) Global Distribution Data for Cattle, Buffaloes, Horses, Sheep, Goats, Pigs, Chickens and Ducks in 2010. Nature Scientific data, 5:180227.doi: 10.1038/sdata.2018.227

Hanan, N.P., L. Prihodko, C.W. Ross, G. Bucini, and A.T. Tredennick. 2020. Gridded Estimates of Woody Cover and Biomass across Sub-Saharan Africa, 2000-2004. ORNL DAAC, Oak Ridge, Tennessee, USA. https://doi.org/10.3334/ORNLDAAC/1777

Jedwab, Remi and Adam Storeygard, “The Average and Heterogeneous Effects of Transportation Investments:
Evidence from Sub-Saharan Africa 1960-2010,”Working Paper 27670, National Bureau of Economic Research
August 2020.

Li, X., Zhou, Y., Zhao, M., & Zhao, X. (2020). A harmonized global nighttime light dataset 1992–2018. Scientific data, 7(1), 168.

Lujala, Päivi; Jan Ketil Rød & Nadia Thieme, 2007. 'Fighting over Oil: Introducing A New Dataset', Conflict Management and Peace Science 24(3), 239-256.

MacDonald, A. M., Bonsor, H. C., Dochartaigh, B. É. Ó., & Taylor, R. G. (2012). Quantitative maps of groundwater resources in Africa. Environmental Research Letters, 7(2), 024009.

Murdock, George Peter, “Africa its peoples and their culture history,” 1959.

Natural Earth (NE) (n.d.). 1:10 million scale dataset. Natural Earth. 

Salehyan, Idean, Cullen S. Hendrix, Jesse Hamner, Christina Case, Christopher Linebarger, Emily Stull, and Jennifer Williams. "Social conflict in Africa: A new database." International Interactions 38, no. 4 (2012): 503-511.

USGS (2003). Global GIS DVD, Mineral Operations of Africa and the Middle East, 2006.

Verdin, K. L., Godt, J. W., Funk, C. C., Pedreros, D., Worstell, B., & Verdin, J. (2007). Development of a global slope dataset for estimation of landslide occurrence resulting from earthquakes (No. 2007-1188). US Geological Survey.

Weidmann, Nils B., Jan Ketil Rød, and Lars-Erik Cederman. 2010. "Representing Ethnic Groups in Space: A New Dataset". Journal of Peace Research 47(4): 491–99.

## Acknowledgements

We acknowledge the production generation of a suite of average radiance composite images using nighttime data from the Visible Infrared Imaging Radiometer Suite (VIIRS) Day/Night Band (DNB) from Earth Observation Group, Payne Institute for Public Policy (https://eogdata.mines.edu/nighttime_light/annual/v20/).
 
